//
//  LzwBnEndTableViewCell.m
//  CoJellyCartoon
//
//  Created by 刘志武 on 16/4/1.
//  Copyright © 2016年 CJG. All rights reserved.
//

#import "LzwBnEndTableViewCell.h"
#import "LzwBniEndCollectCell.h"

@interface LzwBnEndTableViewCell ()<UICollectionViewDataSource, UICollectionViewDelegate>

@property (nonatomic, strong) UIImageView *myImageView;
@property (nonatomic, strong) UILabel *LableTitle;

@property (nonatomic, strong) UICollectionView *myEndCollectView;



@end


@implementation LzwBnEndTableViewCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        [self creatSubViews];
    }
    
    return self;
}


- (void)creatSubViews{
    
    self.myImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 30, 30)];
    self.myImageView.image = [UIImage imageNamed:@"L4.jpg"];
    [self.contentView addSubview:self.myImageView];
    
    self.LableTitle = [[UILabel alloc]initWithFrame:CGRectMake(50, 15, 150, 20)];
    self.LableTitle.text = @"完结动画";
    self.LableTitle.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.LableTitle];
    
    
    self.myEndCollectView = ({
    
        UICollectionViewFlowLayout *myLayOut = [[UICollectionViewFlowLayout alloc]init];
        //设置横向滚动
        myLayOut.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        
        myLayOut.itemSize = CGSizeMake(112, 200);
        
        myLayOut.sectionInset = UIEdgeInsetsMake(0, 10, 10, 10);
        
        UICollectionView *myCollect = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 40, SCREEN_WIDTH, 220) collectionViewLayout:myLayOut];
        myCollect.backgroundColor = [UIColor whiteColor];
        myCollect.delegate = self;
        myCollect.dataSource = self;
    
        myCollect.showsHorizontalScrollIndicator = NO;
        [self.contentView addSubview:myCollect];
        myCollect;
    });
    
    
    [self.myEndCollectView registerClass:[LzwBniEndCollectCell class] forCellWithReuseIdentifier:@"cell"];
    
    
    
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    return self.arrayEnd.count;
    
    
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    LzwBniEndCollectCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    
    
    cell.modelEnd = _arrayEnd[indexPath.row];
    
    return cell;
    
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
    //(@"..ddd.. %ld", indexPath.row);
    
    LzwLatesModel *model = _arrayEnd[indexPath.row];
    
    [self.myDeleGate pushNextPage:model.season_id];
    
    
}


-(void)setArrayEnd:(NSMutableArray<LzwLatesModel *> *)arrayEnd{
    
    _arrayEnd = arrayEnd;
    
    
    [self.myEndCollectView reloadData];
    
}


@end
